package com.mvp.shq.washer.entity.shop;

import android.os.Parcel;
import android.os.Parcelable;

import com.mvp.shq.washer.utils.DataDictionary;
import com.mvp.shq.washer.utils.StringUtils;
import com.shq.mymvp.dao.StringConverter;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Keep;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Unique;

import java.math.BigDecimal;
import java.util.List;
import org.greenrobot.greendao.annotation.Generated;

/**
 * Created by Administrator on 2017/10/11.
 */
@Entity
public class Product{

    /**
     * id : f889756ff55247739353bc2ba59f9d09
     * productName : 蓝月亮香纸
     * imgUrl : /userfiles/9823214827684a349c351e73315f6a29/images/photo/2017/10/u%3D2245805079%2C1292007339%26fm%3D77%26src%3D1009.jpg
     */
    @Id
    private Long dbId;
    private String id;
    private String productName;
    private String productId;//商品Id,收藏列表的时候使用
    private String imgUrl;
    private int sellNum;
    private double cashPrice;
    private double integralPrice;
    private String specText;
    private String productDes;
    private String companyId;
    @Transient
    private List<String> imgList;
    private String imgListStr;
    @Transient
    private List<ShopSpec> specList;
    @Transient
    private String payMode;//支付类型 0积分支付  1现金支付 2混合支付
    @Transient
    private ProductComment comment;
    private int byNum;
    private String isCollect;//0 未收藏  1 已收藏
    private String priceRange;//价格区间
    private boolean isCheck;//选中状态


    @Generated(hash = 1630363814)
    public Product(Long dbId, String id, String productName, String productId, String imgUrl, int sellNum, double cashPrice,
            double integralPrice, String specText, String productDes, String companyId, String imgListStr, int byNum, String isCollect,
            String priceRange, boolean isCheck) {
        this.dbId = dbId;
        this.id = id;
        this.productName = productName;
        this.productId = productId;
        this.imgUrl = imgUrl;
        this.sellNum = sellNum;
        this.cashPrice = cashPrice;
        this.integralPrice = integralPrice;
        this.specText = specText;
        this.productDes = productDes;
        this.companyId = companyId;
        this.imgListStr = imgListStr;
        this.byNum = byNum;
        this.isCollect = isCollect;
        this.priceRange = priceRange;
        this.isCheck = isCheck;
    }

    @Generated(hash = 1890278724)
    public Product() {
    }



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getImgUrl() {
        return DataDictionary.SHOP_IMG_BASE_URL+imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public int getSellNum() {
        return sellNum;
    }

    public void setSellNum(int sellNum) {
        this.sellNum = sellNum;
    }


    public double getCashPrice(){
        return cashPrice;
    }

    public void setCashPrice(double cashPrice) {
        this.cashPrice = cashPrice;
    }


    public double getIntegralPrice() {
        return integralPrice;
    }

    public void setIntegralPrice(double integralPrice) {
        this.integralPrice = integralPrice;
    }

    public String getSpecText() {
        return specText;
    }

    public void setSpecText(String specText) {
        this.specText = specText;
    }

    public String getProductDes() {
        return productDes;
    }

    public void setProductDes(String productDes) {
        this.productDes = productDes;
    }

    public List<String> getImgList() {
        return imgList;
    }

    public void setImgList(List<String> imgList) {
        this.imgList = imgList;
    }

    public List<ShopSpec> getSpecList() {
        return specList;
    }

    public void setSpecList(List<ShopSpec> specList) {
        this.specList = specList;
    }

    public ProductComment getComment() {
        return comment;
    }

    public void setComment(ProductComment comment) {
        this.comment = comment;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getPayMode() {
        BigDecimal decimal = new BigDecimal("0");
        BigDecimal c = BigDecimal.valueOf(getCashPrice());
        BigDecimal i = BigDecimal.valueOf(getIntegralPrice());
        if (c.compareTo(decimal) == 1 && i.compareTo(decimal) == 1){
            return DataDictionary.PAY_MODE_CASH_AND_INTEGRAL;
        }else if (c.compareTo(decimal) == 1){
            return DataDictionary.PAY_MODE_CASH;
        }else {
            return DataDictionary.PAY_MODE_INTEGRAL;
        }

    }

    public void setPayMode(String payMode) {
        this.payMode = payMode;
    }

    public Long getDbId() {
        return dbId;
    }

    public void setDbId(Long dbId) {
        this.dbId = dbId;
    }

    public String getImgListStr() {
        return imgListStr;
    }

    public void setImgListStr(String imgListStr) {
        this.imgListStr = imgListStr;
    }

    public int getByNum() {
        return byNum;
    }

    public void setByNum(int byNum) {
        this.byNum = byNum;
    }

    public String getIsCollect() {
        return isCollect;
    }

    public void setIsCollect(String isCollect) {
        this.isCollect = isCollect;
    }

    public String getPriceRange() {
        return priceRange;
    }

    public void setPriceRange(String priceRange) {
        this.priceRange = priceRange;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    @Override
    public String toString() {
        return "Product{" +
                "dbId=" + dbId +
                ", id='" + id + '\'' +
                ", productName='" + productName + '\'' +
                ", productId='" + productId + '\'' +
                ", imgUrl='" + imgUrl + '\'' +
                ", sellNum=" + sellNum +
                ", cashPrice=" + cashPrice +
                ", integralPrice=" + integralPrice +
                ", specText='" + specText + '\'' +
                ", productDes='" + productDes + '\'' +
                ", companyId='" + companyId + '\'' +
                ", imgList=" + imgList +
                ", imgListStr='" + imgListStr + '\'' +
                ", specList=" + specList +
                ", payMode='" + payMode + '\'' +
                ", comment=" + comment +
                ", byNum=" + byNum +
                ", isCollect='" + isCollect + '\'' +
                ", priceRange='" + priceRange + '\'' +
                '}';
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public boolean getIsCheck() {
        return this.isCheck;
    }

    public void setIsCheck(boolean isCheck) {
        this.isCheck = isCheck;
    }
}
